/*
 * =====================================================================================
 * Copyright (C) 2024 Ingenic Semiconductor Co.,Ltd
 * All Rights Reserved
 *
 * Filename     : mutex.c
 * Author       : Keven <keven.ywhan@ingenic.com>
 * Created      : 2024/05/16 18:23
 * Description  :
 *
 * =====================================================================================
 */

#include "mutex.h"

void mutex_init(struct mutex *lock)
{
	lock->mutex = xSemaphoreCreateMutex();
}
void mutex_destroy(struct mutex *lock)
{
	vSemaphoreDelete(lock->mutex);
}

void mutex_lock(struct mutex *lock)
{
	if( lock->mutex != NULL )
		xSemaphoreTake(lock->mutex, portMAX_DELAY);
}

void mutex_unlock(struct mutex *lock)
{
	if( lock->mutex != NULL )
		xSemaphoreGive(lock->mutex);
}
